# ##########################################
SET( MATH_INCLUDE_FILES
	Include/Math/Vector3fv.hpp
	Include/Math/Vector4fv.hpp
	Include/Math/Matrix44fv.hpp
)

SET( SIMD_MATH_INCLUDE_FILES
	Include/Math/Simd/Simd.hpp
)

SET( SIMD_SSE_MATH_INCLUDE_FILES
	Include/Math/Simd/Sse/Mmx.hpp
	Include/Math/Simd/Sse/Sse1.hpp
	Include/Math/Simd/Sse/Sse2.hpp
	Include/Math/Simd/Sse/Sse3.hpp
	Include/Math/Simd/Sse/Sse4.hpp
	Include/Math/Simd/Sse/Avx.hpp
)

SET( SIMD_NEON_MATH_INCLUDE_FILES
	Include/Math/Simd/Neon/Neon.hpp
)

SET( SIMD_REFERENCE_MATH_INCLUDE_FILES
	Include/Math/Simd/Reference/Reference.hpp
)

SET( INCLUDE_FILES
	${MATH_INCLUDE_FILES}
	${SIMD_MATH_INCLUDE_FILES}
	${SIMD_SSE_MATH_INCLUDE_FILES}
	${SIMD_NEON_MATH_INCLUDE_FILES}
	${SIMD_NONE_MATH_INCLUDE_FILES}
	${SIMD_REFERENCE_MATH_INCLUDE_FILES}
)

# ##########################################
SET( MATH_SOURCE_FILES
	Source/Vector3fv.cpp
)

SET( SIMD_MATH_SOURCE_FILES
	Source/Simd/Simd.cpp
)

SET( SOURCE_FILES
	${MATH_SOURCE_FILES}
	${SIMD_MATH_SOURCE_FILES}
)


# ##########################################
# Let's make things pretty in IDE's.
SOURCE_GROUP( "Math Includes" FILES ${MATH_INCLUDE_FILES} )
SOURCE_GROUP( "Math Source" FILES ${MATH_SOURCE_FILES} )
SOURCE_GROUP( "Math Includes\\Simd" FILES ${SIMD_MATH_INCLUDE_FILES} )
SOURCE_GROUP( "Math Source\\Simd" FILES ${SIMD_MATH_SOURCE_FILES} )
SOURCE_GROUP( "Math Includes\\Simd\\Sse" FILES ${SIMD_SSE_MATH_INCLUDE_FILES} )
SOURCE_GROUP( "Math Source\\Simd\\Sse" FILES ${SIMD_SSE_MATH_SOURCE_FILES} )
SOURCE_GROUP( "Math Includes\\Simd\\Neon" FILES ${SIMD_NEON_MATH_INCLUDE_FILES} )
SOURCE_GROUP( "Math Source\\Simd\\Neon" FILES ${SIMD_NEON_MATH_SOURCE_FILES} )
SOURCE_GROUP( "Math Includes\\Simd\\Reference" FILES ${SIMD_REFERENCE_MATH_INCLUDE_FILES} )


# ##########################################
SET( DEFINITIONS "BUILDING_MATH" )
IF( TARGET_IOS )
	SET( DEFINITIONS "${DEFINITIONS};ARM_NEON_GCC_COMPATIBILITY=1" )
ENDIF()

ADD_LIBRARY( Math-SIMD
	STATIC
	${INCLUDE_FILES}
	${SOURCE_FILES}
)


# ##########################################
#	Set the new target usage requirements.
#	Requires CMake 2.8.11.
TARGET_COMPILE_DEFINITIONS( Math-SIMD
	PRIVATE		BUILDING_MATH
)
TARGET_INCLUDE_DIRECTORIES( Math-SIMD
	PUBLIC		${CMAKE_CURRENT_LIST_DIR}/Include
)
TARGET_LINK_LIBRARIES( Math-SIMD Math )


# ##########################################
# Group the libraries.
SET_PROPERTY( TARGET Math-SIMD PROPERTY FOLDER Libraries )


# ##########################################
# Make a unit test holder for the Math library.
IF( BUILD_UNIT_TESTS )
	ADD_EXECUTABLE( _TestMath-SIMD
		Tests/Main.cpp
		Tests/TestAll.hpp
		Tests/TestVector3fv.hpp
		Tests/TestVector4fv.hpp
		Tests/TestMatrix44fv.hpp
	)
	TARGET_LINK_LIBRARIES( _TestMath-SIMD Math-SIMD GMock )

	ADD_TEST( NAME _TestMath-SIMD COMMAND _TestMath-SIMD )

	# ##########################################
	# Group the tests.
	SET_PROPERTY( TARGET _TestMath-SIMD PROPERTY FOLDER UnitTests )
ENDIF( BUILD_UNIT_TESTS )
